package com.hunau.system.rpc;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.IOException;
import java.net.URI;

/**
 * @program: ruoyi
 * @description:
 * @author: Mr.Liu
 * @create: 2020-03-19 21:09
 **/
//@Configuration
public class Test {
    private static final Logger logger = LoggerFactory.getLogger(Test.class);
    //@Bean(name = "HelloService")
//    public HelloService getHelloService(){
//        String serviceName = HelloService.class.getCanonicalName();
//        File tmpDirFile = new File(System.getProperty("java.io.tmpdir"));
//        File file = new File(tmpDirFile, "lx_rpc_name_service.data");
//        try(RpcAccessPoint rpcAccessPoint = ServiceSupport.load(RpcAccessPoint.class)) {
//            NameService nameService = rpcAccessPoint.getNameService(file.toURI());
//            assert nameService != null;
//            URI uri = nameService.lookupService(serviceName);
//            assert uri != null;
//            logger.info("找到服务{}，提供者: {}.", serviceName, uri);
//            return rpcAccessPoint.getRemoteService(uri, HelloService.class);
//        } catch (IOException e) {
//            logger.error("HelloService远程调用初始化失败");
//            e.printStackTrace();
//            return null;
//        }
//    }

}
